﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using SCADA_SANEST.Models;
using S7.Net;
using System;
using System.Collections.ObjectModel;
using System.Threading;
using System.Threading.Tasks;

namespace SCADA_SANEST.Services
{
    public abstract class PlcBaseService : IDisposable
    {
        public ObservableCollection<PlcSignal> Signals => PlcDevice.Signals;

        protected PlcDeviceStatus PlcDevice;

        protected PlcBaseService(PlcDeviceStatus plcDevice)
        {
            PlcDevice = plcDevice;
        }

        public abstract void LoadSignals();

        public void Start()
        {
            PlcDevice?.StartPolling();
        }

        public void Stop()
        {
            PlcDevice?.StopPolling();
        }

        public void Dispose()
        {
            // không cần Stop polling ở đây nữa, vì PlcDeviceStatus tự lo
        }
    }
}